import java.util.Arrays;
import java.util.List;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;



public class WorkingEmployeesTest {
	private int size;
	private WorkSchedule schedule;
	private Utils utils;
	@Before
	public void setUp(){
		size = 8;
		schedule = new WorkSchedule(size);
		utils = new Utils();
	}
	
	@Test
	public void testWorkingEmployees(){
		List<String> workingEmployeesList = Arrays.asList(schedule.workingEmployees(0, 2));
		schedule = new WorkSchedule(size);
		schedule.setRequiredNumber(5, 0, size-1);
		schedule.addWorkingPeriod("Oskar", 0, 3);
		schedule.addWorkingPeriod("Jake", 0, 3);
		
		//New TestCase: StartTime=0
		utils.UpdatePreviousScheduleList(schedule, size);
		workingEmployeesList = Arrays.asList(schedule.workingEmployees(0, 2));
		Assert.assertTrue(workingEmployeesList.contains("Oskar"));
		Assert.assertTrue(workingEmployeesList.contains("Jake"));
		Assert.assertTrue(workingEmployeesList.size()==2);
		utils.isAllValueUnchanged(schedule);
		
		schedule.addWorkingPeriod("Sebbe", 4, size-1);
		//because we have changed the schedule we need to update our previous list.
		utils.UpdatePreviousScheduleList(schedule, size);
		
		//New TestCase: endTime = size -1
		workingEmployeesList = Arrays.asList(schedule.workingEmployees(0, size-1));
		Assert.assertTrue(workingEmployeesList.contains("Oskar"));
		Assert.assertTrue(workingEmployeesList.contains("Jake"));
		Assert.assertTrue(workingEmployeesList.contains("Sebbe"));
		Assert.assertTrue(workingEmployeesList.size()==3);
		
		//New TestCase: endTime = startTime
		workingEmployeesList = Arrays.asList(schedule.workingEmployees(2, 2));
		Assert.assertTrue(workingEmployeesList.contains("Oskar"));
		Assert.assertTrue(workingEmployeesList.contains("Jake"));
		Assert.assertTrue(workingEmployeesList.size()==2);
		
		
		//New TestCase: starttime > endtime (should return empty array)
		//BUG!
		workingEmployeesList = Arrays.asList(schedule.workingEmployees(2, 1)); //<-BUG
		Assert.assertTrue(workingEmployeesList.isEmpty());
		
		utils.isAllValueUnchanged(schedule);
	}
}
